let payOrderCoinsService = require('./PayOrderCoinsService');
let payOrderCardsService = require('./PayOrderCardsService');
let payOrderNotThingService = require('./PayOrderNotThingService');

const { BusiError, SysError } = require('../exception/exception');

class PayOrderCategoryService {
    constructor(){
        this.serviceMap = {
            "C1": payOrderCoinsService,
            "C2": payOrderCardsService,
            "C3": payOrderNotThingService
        };
    }

    async orderProcess(category, order){
        let service = this.serviceMap[category];
        if(!service){
            throw new BusiError(500, "未找到该服务:" + category);
        }

        await service.process(order);
    }
}

let payOrderCategoryService = new PayOrderCategoryService();
module.exports = payOrderCategoryService;